package com.lemon.ashe.controller;

import com.lemon.ashe.service.AsheService;
import com.lemon.ashe.service.HystrixService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: SpringBootZoo
 * @author: Mr.Young
 * @create: 2021/4/7 21:36
 **/
@RestController
@RequestMapping("/hystrix")
public class HystrixController {
    @Autowired
    private HystrixService hystrixService;

    /**
     * 测试类
     *
     * @return
     */
    @GetMapping({"/hello/{id}", "/hello"})
    public String asheTest(@PathVariable("id") Integer id) {
        return null == id ? "hello ashe" : hystrixService.hello(id);
    }

    /**
     * 测试类
     *
     * @return
     */
    @GetMapping({"/hello/timeout/{id}", "/hello/timeout"})
    public String asheTimeoutTest(@PathVariable("id") Integer id) {
        return null == id ? "hello ashe" : hystrixService.hello_timeout(id);
    }

}
